package com.ruoyi.deeplearn.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.deeplearn.domain.DeepDatasetTag;
import com.ruoyi.deeplearn.service.IDeepDatasetTagService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 数据集标记标签Controller
 *
 * @author 任伟伟
 * @date 2022-12-10
 */
@RestController
@RequestMapping("/deeplearn/marktag")
public class DeepDatasetTagController extends BaseController
{
    @Autowired
    private IDeepDatasetTagService deepDatasetTagService;

    /**
     * 查询数据集标记标签列表
     */
//    @PreAuthorize("@ss.hasPermi('deeplearn:marktag:list')")
    @GetMapping("/list")
    public TableDataInfo list(DeepDatasetTag deepDatasetTag)
    {
        startPage();
        List<DeepDatasetTag> list = deepDatasetTagService.selectDeepDatasetTagList(deepDatasetTag);
        return getDataTable(list);
    }

    /**
     * 导出数据集标记标签列表
     */
//    @PreAuthorize("@ss.hasPermi('deeplearn:marktag:export')")
    @Log(title = "数据集标记标签", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DeepDatasetTag deepDatasetTag)
    {
        List<DeepDatasetTag> list = deepDatasetTagService.selectDeepDatasetTagList(deepDatasetTag);
        ExcelUtil<DeepDatasetTag> util = new ExcelUtil<DeepDatasetTag>(DeepDatasetTag.class);
        util.exportExcel(response, list, "数据集标记标签数据");
    }

    /**
     * 获取数据集标记标签详细信息
     */
//    @PreAuthorize("@ss.hasPermi('deeplearn:marktag:query')")
    @GetMapping(value = "/{moduleId}")
    public AjaxResult getInfo(@PathVariable("moduleId") Long moduleId)
    {
        return success(deepDatasetTagService.selectDeepDatasetTagByModuleId(moduleId));
    }

    /**
     * 新增数据集标记标签
     */
//    @PreAuthorize("@ss.hasPermi('deeplearn:marktag:add')")
    @Log(title = "数据集标记标签", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DeepDatasetTag deepDatasetTag)
    {
        return toAjax(deepDatasetTagService.insertDeepDatasetTag(deepDatasetTag));
    }

    /**
     * 修改数据集标记标签
     */
//    @PreAuthorize("@ss.hasPermi('deeplearn:marktag:edit')")
    @Log(title = "数据集标记标签", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DeepDatasetTag deepDatasetTag)
    {
        return toAjax(deepDatasetTagService.updateDeepDatasetTag(deepDatasetTag));
    }

    /**
     * 删除数据集标记标签
     */
//    @PreAuthorize("@ss.hasPermi('deeplearn:marktag:remove')")
    @Log(title = "数据集标记标签", businessType = BusinessType.DELETE)
	@DeleteMapping("/{moduleIds}")
    public AjaxResult remove(@PathVariable Long[] moduleIds)
    {
        return toAjax(deepDatasetTagService.deleteDeepDatasetTagByModuleIds(moduleIds));
    }
}
